home *** CD-ROM | disk | FTP | other *** search
- Path: news1.cris.com!mariner!Crawford
- From: Crawford@mariner.cris.com (CRAWFORD)
- Newsgroups: comp.lang.c
- Subject: Re: What should be returned?
- Date: 17 Jan 1996 12:34:54 -0500
- Organization: Concentric Internet Services
- Message-ID: <Crawford.821899744@mariner>
- References: <4dj8pv$cjd@eng_ser1.erg.cuhk.hk>
- Reply-To: crawford@iac.net
- NNTP-Posting-Host: mariner.cris.com
-
- phsung@cs.cuhk.hk (the CAReLess boy) writes:
- >Hi, all,
- > It's said that the function main must return an integer value
- >but I just don't know what value should be returned. Also, if I quit
- >main by exit(), what's the use of the return value?
- > Any help?
-
- exit() also causes a value to be returned from main, the POSIX
- prottype for exit() is:
-
- void exit(int status);
-
- As for what value should be returned, there should be two
- macros defined in stdlib.h, EXIT_SUCCESS and EXIT_FAILURE. Use
- those as the values to return from main and call exit() with.
-
- In the UNIX world (and, I believe, DOS), the standard is to
- return zero on success and non-zero on a failure. That's what the
- macros evaluate to, but I'd use the macros anyway, since they're easy
- to understand.
-
- --
- Creature of the wheel, master of the internal combustion engine.
-
- Robert Crawford crawford@iac.net
- http://www.iac.net/~crawford
-